<?php

Raise::load('core.RaiseStaticClass');

/**
 * RaiseDns - DNS helper class
 * for DNS related functionality
 *
 * @author Sam-Mauris Yong <hellclanner at live dot com>
 * @license http://www.opensource.org/licenses/bsd-license New BSD License
 * @package Raise.Core
 * @since 1.2
 */
class RaiseDns  extends RaiseStaticClass {

    /**
     * Get the host name by IP Address
     * @param IpAddress|string $ip The host IP address to fetch
     * @return string The host name
     * @static
     */
    public static function getHostByAddress($ip){
        return gethostbyaddr($ip);
    }

    /**
     * Get a list of IPv4 addresses assigned to the host name
     * @param string $name The host name to fetch from
     * @return array An array of IPv4 addresses
     * @static
     */
    public static function getAddressesByName($name){
        return gethostbynamel($name);
    }

    /**
     * Get the IPv4 address assigned to the host name
     * @param string $name The host name to fetch from
     * @return string The IPv4 address
     * @static
     */
    public static function getAddressByName($name){
        return gethostbyname($name);
    }

    /**
     * Check DNS records corresponding to a given Internet hostname or IpAddress
     * @param IpAddress|string $host The host to check DNS recods
     * @param string $type The type of record to check for. Can be: A, MX, NS, SOA, PTR, CNAME, AAAA, A6, SRV, NAPTR, TXT or ANY.
     * @return boolean Returns TRUE if any records are found; returns FALSE if no records were found or if an error occurred.
     * @link http://php.net/checkdnsrr
     * @static
     */
    public static function checkRecord($host, $type = 'MX'){
        return checkdnsrr($host,$type);
    }
    
}

